package soen6441;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

class AddressFactory {
    static EmailAddress create(String emailString){
        Pattern emailRegex = Pattern.compile("(.*?)@(.*?)$");
        Matcher email = emailRegex.matcher(emailString);
        if ( email.find() ) {
            return new EmailAddressImpl(email.group(1), email.group(2));
        } else {
            return new NullEmailAddress();
        }
    }
}
